//
//  GJFPlotDetailHeaderView.m
//  Wedding
//
//  Created by 郭静芬 on 2016/12/23.
//  Copyright © 2016年 郭静芬. All rights reserved.
//

#import "GJFPlotDetailHeaderView.h"

@interface GJFPlotDetailHeaderView ()
@property (nonatomic, strong) UIImageView *imageV;
@property (nonatomic, strong) UILabel *title;
@property (nonatomic, strong) UILabel *category;
@end

@implementation GJFPlotDetailHeaderView

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        
        [self.imageV mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.right.top.bottom.mas_equalTo(self).mas_offset(0);
        }];
        UIView *bgView = [[UIView alloc] init];
        bgView.alpha = 0.5;
        bgView.backgroundColor = [UIColor blackColor];
        [self addSubview:bgView];
        [bgView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.right.top.bottom.mas_equalTo(self).mas_offset(0);
        }];
        
        [self.category mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(self.title).mas_offset(0);
            make.right.mas_equalTo(self.title).mas_offset(0);
            make.bottom.mas_equalTo(self.mas_bottom).mas_offset(-10 * YY);
            make.height.mas_equalTo(20 * YY);
        }];
        
        [self.title mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(self).mas_offset(15 * XX);
            make.right.mas_equalTo(self).mas_offset(-15 * XX);
            make.bottom.mas_equalTo(self.category.mas_top).mas_offset(-10 * YY);
            make.height.mas_equalTo(20 * YY);
        }];
        
        
    }
    return self;
}

- (void)setPlotModel:(GJFPlotModel *)plotModel {
    _plotModel = plotModel;
    [self.imageV sd_setImageWithURL:[NSURL URLWithString:plotModel.cover_path] placeholderImage:[UIImage imageNamed:@"占位图"]];
    self.title.text = plotModel.title?:@"";
    self.category.text = plotModel.category_name?:@"";
}

#pragma mark - 懒加载
- (UIImageView *)imageV {
    if (!_imageV) {
        _imageV = [[UIImageView alloc] init];
        [self addSubview:_imageV];
    }
    return _imageV;
}
- (UILabel *)title {
    if (!_title) {
        _title = [[UILabel alloc] init];
        _title.textColor = [UIColor whiteColor];
        _title.font = [UIFont boldSystemFontOfSize:20 * XX];
        [self addSubview:_title];
    }
    return _title;
}
- (UILabel *)category {
    if (!_category) {
        _category = [[UILabel alloc] init];
        _category.textColor = [UIColor whiteColor];
        _category.font = [UIFont systemFontOfSize:15 * XX];
        [self addSubview:_category];
    }
    return _category;
}
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
